package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.mapper.DtsPermissionMapper;
import com.qf.pojo.DtsPermission;
import com.qf.service.DtsPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author Cc
 * @version 1.0
 */
@Service
public class DtsPermissionServiceImpl implements DtsPermissionService {

    @Autowired
    private DtsPermissionMapper dtsPermissionMapper;

    @Override
    public Set<String> queryByRoleIds(Integer[] ids) {
        //设置查询条件
        QueryWrapper<DtsPermission> wrapper = new QueryWrapper<>();
        wrapper.eq("deleted", false);
        wrapper.in("role_id", ids);
        List<DtsPermission> dtsPermissions = dtsPermissionMapper.selectList(wrapper);

        Set<String> set = new HashSet<>();
        for (DtsPermission permission : dtsPermissions) {
            set.add(permission.getPermission());
        }


        return set;
    }
}
